import java.awt.*;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.util.Random;

public class JustVisitingUI extends JFrame {

	private JPanel contentPane;

	/**
	 * Create the frame.
	 */
	public JustVisitingUI() {
		String jokes[] = {  "This is joke1",
							"This is joke2",
							"This is joke3",
							"This is joke4",
							"This is joke5"
						};
		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 640, 427);
		contentPane =  new ImagePanel(new ImageIcon("Graphics/JustVisitingUIBG.png").getImage());
		this.setTitle("Bumubisita lang.");
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		
		
		ImageIcon exitPic = new ImageIcon("Graphics/ReturnToGame.png");
		ImageIcon exitPicOver = new ImageIcon("Graphics/ReturnToGameOver.png");
		JButton exitButton = new JButton(exitPic);
		exitButton.setBounds(5, 5, 474, 462);
		
		JLabel jokeLabel = new JLabel(jokes[new Random().nextInt(5)]);
		jokeLabel.setBounds(150, 0, 474, 462);
		jokeLabel.setFont(new Font("Stencil", Font.ITALIC, 22));
		jokeLabel.setVisible(true);
		
		exitButton.setBounds(0, 0, 62, 28);
		
		
		exitButton.setBorderPainted(false);
		exitButton.setContentAreaFilled(false);
		exitButton.setOpaque(false);
		exitButton.setRolloverEnabled(true);
		exitButton.setRolloverIcon(exitPicOver);
		exitButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitButtonPressed(evt);
            }
        });
		contentPane.add(jokeLabel);
		contentPane.add(exitButton);
		this.setVisible(true);
		
		
		
	}
	
	private void exitButtonPressed(java.awt.event.ActionEvent e){
		
		NextPlayerCommand nextPlayerCommand = new NextPlayerCommand();
		nextPlayerCommand.execute();
		this.dispose();
		
		
	}
	
}
